/* Register the related commands.
var dialogPath = FCKConfig.PluginsPath + 'flvPlayer/flvPlayer.html';
var flvPlayerDialogCmd = new FCKDialogCommand( FCKLang["DlgFLVPlayerTitle"], FCKLang["DlgFLVPlayerTitle"], dialogPath, 600, 480 );
FCKCommands.RegisterCommand( 'flvPlayer', flvPlayerDialogCmd ) ;

// Create the Flash toolbar button.
var oFlvPlayerItem		= new FCKToolbarButton( 'flvPlayer', FCKLang["DlgFLVPlayerTitle"]) ;
oFlvPlayerItem.IconPath	= FCKPlugins.Items['flvPlayer'].Path + 'flvPlayer.gif' ;

FCKToolbarItems.RegisterItem( 'flvPlayer', oFlvPlayerItem ) ;			
// 'Flash' is the name used in the Toolbar config.
*/


var iframeWindow = null;
CKEDITOR.plugins.add( 'flvPlayer',
{
	init : function( editor )
	{
		editor.ui.addButton( 'flvPlayer',
			{
				label : 'FLV Media Player',
				command : 'flvPlayer',
				icon: this.path + 'flvPlayer.gif'
			});
		var selectComponentCommand = editor.addCommand( 'flvPlayer', new CKEDITOR.dialogCommand( 'flvPlayer' ) );
		selectComponentCommand.canUndo = false;

		var me = this;
		CKEDITOR.dialog.add( 'flvPlayer', function () {
		  return {
			 title : 'FLV Media Player',
			 minWidth : 600,
			 minHeight : 480,
			 contents :
				   [
					  {
						 id : 'iframe',
						 label : 'FLV Media Player',
						 expand : true,
						 elements :
							   [
								  {
									 type : 'iframe',
									 src : me.path + 'flvPlayer.html',
									 width : '100%',
									 height : '100%',
									 onContentLoad : function() {
										var iframe = document.getElementById(this._.frameId);
										iframeWindow = iframe.contentWindow;
									 }
								  }
							   ]
					  }
				   ],
			 onOk : function() {

				if(iframeWindow.document.getElementById('btnComponents').value != ''){
					this._.editor.insertHtml(iframeWindow.document.getElementById('btnComponents').value) ;	
				}else{
					alert('Please select a component.');
					return false;
				}

			  }
		  };
		} );

	},

	requires : [ 'iframedialog' ]
} );

